package com.yycx.module.bus.provider.handler.haiying.common;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.mybatis.interceptor.PageInterceptor;
import com.yycx.common.mybatis.model.PageParams;
import com.yycx.common.mybatis.model.ResultBody;
import com.yycx.common.mybatis.query.CriteriaQuery;
import com.yycx.module.admin.client.entity.BaseUser;
import com.yycx.module.bus.client.entity.BusCustom;
import com.yycx.module.bus.client.entity.BusDept;
import com.yycx.module.bus.client.entity.hy.BusPaymentOrder;
import com.yycx.module.bus.client.entity.hy.HyOrder;
import org.springframework.stereotype.Component;

/**
 * 认款使用明细
 *
 * @author zyf
 */
@Component
public class PaymentOrderSelectPageListHandler implements PageInterceptor<BusPaymentOrder> {


    @Override
    public ResultBody validate(CriteriaQuery cq, EntityMap params) {
        return ResultBody.ok();
    }

    @Override
    public void prepare(CriteriaQuery<BusPaymentOrder> cq, PageParams pageParams, EntityMap params) {
        Long paymentId = cq.getLong("paymentId");
        cq.select(BusPaymentOrder.class, "*");
        cq.select(HyOrder.class, "sendDate", "orderNo", "saleManName", "totalSaleAmount","businessCode");
        cq.select(BusCustom.class, "customName");
        cq.select(BusDept.class, "deptName");
        cq.select(BaseUser.class, "nickName");
        cq.eq(true, "paymentId", paymentId);
        cq.orderByDesc("ho.createTime");
        cq.createJoin(HyOrder.class);
        cq.createJoin(BusCustom.class);
        cq.createJoin(BusDept.class).setMainAlias("ho").setMainField("deptId").setJoinField("deptId");
        cq.createJoin(BaseUser.class).setMainAlias("ho").setMainField("userId").setJoinField("userId");
    }

}
